- content_for(:panel_heading) do
  = "ApiV2 测试"
%label
  %a{ :href => "http://www.udesk.cn/doc/apiv2/im/", :title => "文档", target: '_blank' }
    文档
%form{:method => 'POST', :action => "/projects/#{@project.id}/set_settings_v2" }
  = hidden_field_tag :authenticity_token, form_authenticity_token
  %input{:type => 'text', :name => 'id',  :value => @project.id, :hidden => true }

  %table{:width => '800px'}
    %tr
      %td{:width => '200px'}
        %label{:for => 'server_domain'} 
        服务器域名:
        %input{:type => 'text',:name => 'server_domain',  :value => @rds[:server_domain] || ""}
      %td{:width => '200px'}
        %label{:for => 'email'}
        管理员email:
        %input{:type => 'text',:name => 'email',  :value => @rds[:email] || ""}
      %td{:width => '200px'}
        %label{:for => 'password'}
        管理员password:
        %input{:type => 'password',:name => 'password',  :value => @rds[:password] || ""}
    %tr
      %td
        %input{:type => 'submit', :value => '保存'}
    %tr
      %td
        推送地址:
        = "http://imdev.udeskmonkey.com:4568/projects/#{@project.id}/recv_v2"
%p
%hr
%h2 请求token
%p
= "https://#{@rds[:server_domain]}/open_api_v1/log_in"
%p
= "headers content-type: application/json"
%p
= "{\"email\": \"#{@rds[:email]}\", \"password\": \"#{@rds[:password]}\" }"
%p
= "open_api_auth_token: #{@rds[:open_api_auth_token]}"
%form{:method => 'POST', :action => "/projects/#{@project.id}/get_open_api_auth_token_v2" }
  = hidden_field_tag :authenticity_token, form_authenticity_token
  %input{:type => 'submit', :value => '重新请求'}
%p

%p
%hr
%h2 创建客户
%form{:method => 'POST', :action => "/projects/#{@project.id}/get_customer_v2" }
  = hidden_field_tag :authenticity_token, form_authenticity_token
  open_api_token
  = "#{@rds[:open_api_token]}"
  %p
  %input{:type => 'text',:name => 'open_api_token',  :value => @rds[:open_api_token] || "abc"}
  email 
  %input{:type => 'text',:name => 'custome_email',  :value => @rds[:custome_email] || ""}
  nick_name 
  %input{:type => 'text',:name => 'custome_nick_name',  :value => @rds[:custome_nick_name] || "abc"}
  %p
  其它info  
  %input{:type => 'text',:name => 'customer_info',  :value => @rds[:customer_info] || ""}
  other_emails  
  %input{:type => 'text',:name => 'customer_other_emails',  :value => @rds[:customer_other_emails] || ""}
  tags  
  %input{:type => 'text',:name => 'customer_tags',  :value => @rds[:customer_tags] || ""}

  %input{:type => 'submit', :value => '请求'}
%p
= "#{@rds[:customer_id]}"
%p
= "#{@rds[:customer]}"
%p
%hr

%h2 请求会话
%p
= "当前客户 #{@rds[:customer_token]}"
%form{:method => 'POST', :action => "/projects/#{@project.id}/get_session_v2" }
  = hidden_field_tag :authenticity_token, form_authenticity_token
  会话类型 robot/agent
  %p
  %input{:type => 'text',:name => 'assign_type',  :value => @rds[:assign_type] || "robot"}
  %p
  请求客服 类型为agent有效 
  %p
  %input{:type => 'text',:name => 'agent_id',  :value => @rds[:agent_id] || ""}
  %p
  请求客服组 类型为agent有效 
  %p
  %input{:type => 'text',:name => 'group_id',  :value => @rds[:group_id] || ""}
  %p
  channel
  %p
  %input{:type => 'text',:name => 'channel',  :value => @rds[:channel] || ""}
  %p
  robot_role_id
  %p
  %input{:type => 'text',:name => 'robot_role_id',  :value => @rds[:robot_role_id] || ""}
  %p

  %input{:type => 'submit', :value => '请求'}
%p
最后返回
%p 
会话类型
= @rds[:assign_type]
%p 
会话id
= @rds[:im_sub_session_id]
%p
= @rds[:session_info]
%p
%hr

%h2 发送消息
%form{:method => 'POST', :action => "/projects/#{@project.id}/send_message_v2" }
  = hidden_field_tag :authenticity_token, form_authenticity_token
  类型
  %input{:type => 'text',:name => 'type',  :value => @rds[:type] || "message"}
  内容
  %input{:type => 'text',:name => 'content',  :value => @rds[:content] || "你好"}
  %input{:type => 'submit', :value => '发送'}
%p

返回
= @rds[:send_message_v2_resp]

%p
%hr

%h2 排队查询
%form{:method => 'POST', :action => "/projects/#{@project.id}/queue_status_v2" }
  = hidden_field_tag :authenticity_token, form_authenticity_token
  customer_token
  %input{:type => 'text',:name => 'customer_token',  :value => @rds[:open_api_token]}
  %input{:type => 'submit', :value => '查询'}
%p

返回
= @rds[:queue_res]

%h2 客户状态查询
%form{:method => 'POST', :action => "/projects/#{@project.id}/customer_status_v2" }
  = hidden_field_tag :authenticity_token, form_authenticity_token
  customer_token
  %input{:type => 'text',:name => 'customer_token',  :value => @rds[:open_api_token]}
  web_token
  %input{:type => 'text',:name => 'web_token',  :value => @rds[:web_token]}
  sdk_token
  %input{:type => 'text',:name => 'sdk_token',  :value => @rds[:sdk_token]}
  session_key
  %input{:type => 'text',:name => 'session_key',  :value => @rds[:session_key]}
  %input{:type => 'submit', :value => '查询'}
%p

返回
= @rds[:customer_status_res]

%p
%hr
%p
推送结果
%form{ :method => 'POST', :action => "/projects/#{@project.id}/cls_push_v2" }
  = hidden_field_tag :authenticity_token, form_authenticity_token
  %input{:type => 'submit', :value => '清空'}
%p
<textarea rows="20" cols = "150"> #{@rds.get(:push_info)}</textarea>

= render 'survey_vote', rds: @rds, project: @project



= link_to 'Back', projects_path
